package foundation.factorial_calculation;

import java.util.Scanner;

/**
 * 输入一个正整数n，输出n!的值。
 * 其中n!=1*2*3*…*n。
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[1000000];
        int head = 0, tail = 0, p = 0; // 表示最后一个数字
        if (n == 0 || n == 1) {
            System.out.println(1);
            return;
        }
        arr[0] = 1;
        for (int i = 2; i <= n; i++) {
            // 给每一个有效位乘
            for (int j = head; j <= tail; j++) {
                p = arr[j] * i + p;
                arr[j] = p % 10;
                p = p / 10;
            }
            while (p != 0) {
                tail ++;
                arr[tail] = p % 10;
                p = p / 10;
            }
        }
        for (int i = tail; i >= 0; --i) {
            System.out.print(arr[i]);
        }
    }
}
